<div class="grid50"><div class="rad">
<table class="grids">
  <thead>
    <tr>
      <th colspan="2">Data Outlet</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>ID Outlet</td>
      <td><input type="text" name="outlet_id" value="<?php echo $init["outlet"]["outlet_id"] ?>" readonly="readonly" size="45"/></td>
    </tr>
    <tr>
      <td>Nama Outlet</td>
      <td><input type="text" name="outlet_name" value="<?php echo $init["outlet"]["outlet_name"] ?>" size="45" required /></td>
    </tr>
    <tr>
      <td>Status Aktif ?</td>
      <td><input type="checkbox" name="active_status" checked="checked" value="1" /></td>
    </tr>
    <tr>
      <td style="vertical-align: top;">Alamat</td>
      <td><textarea style="resize: none;" rows="4" name="address" cols="40" required ><?php echo $init["outlet"]["address"] ?></textarea></td>
    </tr>
    <tr>
      <td>Kota</td>
      <td><input type="text" name="city" value="<?php echo $init["outlet"]["city"] ?>" size="25" required /></td>
    </tr>
    <tr>
    <td>Provinsi</td>
      <td>
        <select name="province">
          <option value=""></option>
          <?php 
            foreach ($complement["province"] as $key) {
              if($key->province_id == $init["outlet"]["province_id"])
                { echo '<option value="'.$key->province_id.'" selected="selected" >'.$key->province_name.'</option>'; }
              else
                { echo '<option value="'.$key->province_id.'" >'.$key->province_name.'</option>'; }
            }
          ?>
        </select>
      </td>
    </tr>
    <tr>
      <td>Kode Pos</td>
      <td><input type="text" name="post_code" value="<?php echo $init["outlet"]["post_code"]; ?>" size="25" /></td>
    </tr>
    <tr>
      <td>Nomor Telp. Outlet</td>
      <td><input type="tel" name="outlet_phone" value="<?php echo $init["outlet"]["phone"] ?>" size="25" placeholder="62xxx" required/></td>
    </tr>
    <tr>
      <td>Struktur Bisnis</td>
      <td>
        <select name="business_structure">
        <?php 
          foreach ($complement["business_structure"] as $key) {
            if($key["field_key"] == $init["outlet"]["business_structure"])
              { echo '<option value="'.$key["field_key"].'" selected="selected" >'.$key["field_val"].'</option>'; }
            else
              { echo '<option value="'.$key["field_key"].'">'.$key["field_val"].'</option>'; }
          }
        ?>
        </select>
      </td>
    </tr>
  </tbody>
</table>
</div></div>

<div class="grid50"><div class="rad">
  <table class="grids">
    <thead>
      <tr>
        <th colspan="3">Eload</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td colspan="3" style="text-align: right">
          <!-- Klik icon untuk menambah record baru -->
          <!-- <img src='<?php echo base_url(); ?>file/images/add.png' title='Tambah data Eload' class='new-row' onclick='new_row()' /> -->
        </td>
      </tr>
    <?php 
      if($init["eloads"]) :
        $x = 1;
      // print_r($init["eloads"]);
        foreach ($init["eloads"] as $key) :
    ?>
      <tr class="eload_number" id="eload_<?php echo $x; ?>">
        <td>Nomor Eload</td>
        <td colspan="2"><input type="text" size="25" value="<?php echo $key["eload_number"];?>" name="eload_number[]" required/></td>
      </tr>
    <?php // if(isset($key["user_mfino"])) : ?>
      <tr class="user_mfino" id="mfino_<?php echo $x++; ?>">
        <td>User M-Fino</td>
        <td colspan="2"><input type="input" name="mfino[]" size="25" disabled="disabled" value="<?php echo $key["user_mfino"] ?>"></td>
        <?php if($x-1 != '1') :?>
        <td><img src='<?php echo base_url(); ?>file/images/cross-script.png' alt='hapus' onclick='remove_row(<?php echo $x-1; ?>)'></td>
        <?php endif; ?>
      </tr>
    <?php endforeach; else :?>
      <tr class="eload_number" id="eload_1">
        <td>Nomor Eload</td>
        <td colspan="2"><input type="tel" name="eload_number[]" size="25" placeholder="62xxx"  /></td>
      </tr>
    <?php endif; ?>
    </tbody>
  </table>
</div></div>

<div class="grid50"><div class="rad">
<table class="grids">
  <thead>
    <tr>
      <th colspan="2">Informasi Tambahan</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Status Outlet</td>
      <td>
        <select name="outlet_status">
          <?php 
            foreach ($complement["outlet_status"] as $key) {
              if($key["field_val"] == $init["oData"]["outlet_status"]) 
                { echo '<option value="'.$key["field_key"].'" selected="selected">'.$key["field_val"].'</option>'; }
              else 
                { echo '<option value="'.$key["field_key"].'">'.$key["field_val"].'</option>'; }
            }
          ?>
        </select>
      </td>
    </tr>
    <tr>
      <td>Tipe Outlet</td>
      <td>
        <select name="tipe_outlet">
          <?php 
            foreach ($complement["tipe_outlet"] as $key) {
              if($key["field_val"] == $init["oData"]["outlet_type"]) 
                { echo '<option value="'.$key["field_key"].'" selected="selected">'.$key["field_val"].'</option>'; }
              else 
                { echo '<option value="'.$key["field_key"].'">'.$key["field_val"].'</option>'; }
            }
          ?>
        </select>
      </td>
    </tr>
    <tr>
      <td>Ukuran Outlet</td>
      <td>
        <select name="outlet_size">
          <?php 
            foreach ($complement["outlet_size"] as $key) {
              if($key["field_val"] == $init["oData"]["outlet_size"]) 
                { echo '<option value="'.$key["field_key"].'" selected="selected">'.$key["field_val"].'</option>'; }
              else 
                { echo '<option value="'.$key["field_key"].'">'.$key["field_val"].'</option>'; }
            }
          ?>
        </select>
      </td>
    </tr>
    <tr>
      <td>Lokasi Outlet</td>
      <td>
        <select name="outlet_location">
          <?php 
            foreach ($complement["outlet_location"] as $key) {
              if($key["field_val"] == $init["oData"]["outlet_location"]) 
                { echo '<option value="'.$key["field_key"].'" selected="selected">'.$key["field_val"].'</option>'; }
              else 
                { echo '<option value="'.$key["field_key"].'">'.$key["field_val"].'</option>'; }
            }
          ?>
        </select>
      </td>
    </tr>
    <tr>
      <td>Kepemilikan Outlet</td>
      <td>
        <select name="outlet_ownership">
          <?php 
            foreach ($complement["outlet_ownership"] as $key) {
              if($key["field_val"] == $init["oData"]["outlet_ownership"]) 
                { echo '<option value="'.$key["field_key"].'" selected="selected">'.$key["field_val"].'</option>'; }
              else 
                { echo '<option value="'.$key["field_key"].'">'.$key["field_val"].'</option>'; }
            }
          ?>
        </select>
      </td>
    </tr>
    <tr>
      <td>Fokus Usaha</td>
      <td>
        <select name="business_focus">
          <?php 
            foreach ($complement["business_focus"] as $key) {
              if($key["field_val"] == $init["oData"]["outlet_business_focus"]) 
                { echo '<option value="'.$key["field_key"].'" selected="selected">'.$key["field_val"].'</option>'; }
              else 
                { echo '<option value="'.$key["field_key"].'">'.$key["field_val"].'</option>'; }
            }
          ?>
        </select>
      </td>
    </tr>
    <tr>
      <td>Tipe Pelanggan</td>
      <td>
        <select name="customer_type">                         
          <?php 
            foreach ($complement["customer_type"] as $key) {
              if($key["field_val"] == $init["oData"]["outlet_customer_type"]) 
                { echo '<option value="'.$key["field_key"].'" selected="selected">'.$key["field_val"].'</option>'; }
              else 
                { echo '<option value="'.$key["field_key"].'">'.$key["field_val"].'</option>'; }
            }
          ?>
        </select>
      </td>
    </tr>
    <tr>
      <td>Ukuran Usaha</td>
      <td>
        <select name="size_of_business">
          <?php 
            foreach ($complement["size_of_business"] as $key) {
              if($key["field_val"] == $init["oData"]["outlet_size_of_business"]) 
                { echo '<option value="'.$key["field_key"].'" selected="selected">'.$key["field_val"].'</option>'; }
              else 
                { echo '<option value="'.$key["field_key"].'">'.$key["field_val"].'</option>'; }
            }
          ?>
        </select>
      </td>
    </tr>
    <tr>
      <td>Nomor Smartfren</td>
      <td><input type="tel" value="<?php echo $init["oData"]["outlet_smart_no"] ?>" name="smart_no" size="25" placeholder="62xxx"/></td>
    </tr>
    <!-- <tr>
      <td>Ekspansi</td>
      <td><input type="checkbox" id="is_expansion" name="is_expansion" value="1" <?php if($init["oData"]["outlet_is_expansion"]) {echo 'selected="selected"'; } ?>/></td>
    </tr>
    <tr>
      <td>Paket Ekspansi</td>
      <td>
        <select name="expansion_pack">
          <?php 
            foreach ($complement["expansion_list"] as $key) {
              if($key["field_val"] == $init["oData"]["outlet_expansion_package"]) 
                { echo '<option value="'.$key["field_key"].'" selected="selected">'.$key["field_val"].'</option>'; }
              else 
                { echo '<option value="'.$key["field_key"].'">'.$key["field_val"].'</option>'; }
            }
          ?>
        </select>
      </td>
    </tr> -->
  </tbody>
</table>
</div></div>
<img src="" alt="">
<div class="clear"></div>

<script type="text/javascript">
  $(document).ready(function(){

  });

  function new_row() {
    var all_row = $('tr.eload_number').length;
    var add_row = "<tr class='eload_number' id='eload_"+parseInt(all_row + 1)+"'><td>Nomor Eload</td>"+
                  "<td><input type='text' size='25' colspan='2' name='eload_number[]'></td>"+
                  "<td><img src='<?php echo base_url(); ?>file/images/cross-script.png' alt='hapus' onclick='remove_row("+parseInt(all_row + 1)+")'></td>"+
                  "</tr>";
    $("tr#eload_"+all_row).after(add_row);
  }

  function remove_row(row) {
    $("tr#eload_"+row).remove();
    $("tr#mfino_"+row).remove();
  }
</script>